<template>
  <div class="tabBox">
      <el-tabs v-model="activeName" type="card" @tab-click="handleClick">
        <el-tab-pane v-if="this.menuList.includes('levelStudent')" label="管理层级" name="hierarchy">
          <hierarchy></hierarchy>
        </el-tab-pane>
        <el-tab-pane v-if="this.menuList.includes('studentAdminister')" label="管理学生" name="student">
          <student></student>
        </el-tab-pane>
      </el-tabs>
    </div>
</template>
<script>
import student from './components/student'
import hierarchy from './components/hierarchy'
export default {
  components: {
    student,
    hierarchy
  },
  data () {
    return {
      activeName: '',
      activeList: ['hierarchy', 'student'],
      menuList: []
    }
  },
  created () {
    this.menuList = sessionStorage.getItem('list')
    let router = this.$router.history.current.path.substring(1)
    if (this.$cookies.get('menu') === router) {
      if (this.activeList.includes(this.$cookies.get('activeName'))) {
        this.activeName = this.$cookies.get('activeName')
      }
    }
    if (this.menuList.includes('levelStudent')) {
      this.activeName = 'hierarchy'
    } else {
      this.activeName = 'student'
    }
  },
  methods: {
    handleClick () {
      this.$cookies.set('activeName', this.activeName)
    }
  }
}
</script>
